package com.chen.common;

import org.apache.commons.lang3.StringUtils;
import org.springframework.core.env.Environment;
import org.springframework.stereotype.Component;

import lombok.Data;

/**
 * @Description
 * @Author Pengwei
 * @CreatDate 2021/11/12 01:49
 */
@Data
@Component
public class PropertiesUtil {

    private static Environment env;

    public PropertiesUtil(Environment env) {
        this.env = env;
    }

    public static String get(String key) {
        String property = env.getProperty(key);
        return property;
    }

    public static String get(String key, String defaultValue) {
        String property = env.getProperty(key);
        if (StringUtils.isBlank(property)) {
            return defaultValue;
        }
        return property;
    }
}
